/**
 * 所有的ajax服务调用
 */
CommonService = {
	'getAllProvince': function(){
		var lst_param = new Array();
		var str_param = lst_param.join('&');
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/common/getAllProvince',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
				
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'getCityListByProvinceId': function(province_id){
		// 登陆功能
		var lst_param = new Array();
		lst_param.push('province_id=' + province_id);
		var str_param = lst_param.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/common/getCityListByProvinceId',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
				
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'getDistrictListByCityId': function(city_id){
		// 登陆功能
		var lst_param = new Array();
		lst_param.push('city_id=' + city_id);
		var str_param = lst_param.join('&');

		var result = null;		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/common/getDistrictListByCityId',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
				
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
};
AdminService = {
	'Login' : function(user_id, pwd) {
		// 登陆功能
		var lst_sku = new Array();
		lst_sku.push('user_id=' + user_id);
		lst_sku.push('password=' + pwd);
		var str_param = lst_sku.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/admin/login',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
				
			},
			error : function(e) {
				result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
			}
		});
		return result;
	},
	'Logout' : function(user_id, pwd) {
		// 登陆功能
		var lst_param = new Array();
		lst_param.push('user_id=' + user_id);
		var str_param = lst_param.join('&');
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/admin/logout',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
        	  error : function(e, err_name, err_text) {
        		  result = {};
        		  result.IsSuccess = 0;
        		  result.ErrorMsg = err_text;
        		  result.ErrorCode = 4;
        	  }
		});
		return result;
	},
};


PromoterService = {
	'SearchPromoterList': function(promoter_id, cellphone, promoter_type, promoter_name, page_index, page_size){
		// 申请提现
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' + promoter_id);
		lst_sku.push('cellphone=' 	+ cellphone);
		lst_sku.push('promoter_type=' + promoter_type);
		lst_sku.push('promoter_name=' + promoter_name);
		lst_sku.push('page_index=' 	+ page_index);
		lst_sku.push('page_size=' 	+ page_size);
		var str_param = lst_sku.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/searchPromoterList',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'SearchAmountList': function( promoter_id, page_index, page_size){
		// 申请提现
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' + promoter_id);
		lst_sku.push('page_index=' 	+ page_index);
		lst_sku.push('page_size=' 	+ page_size);
		var str_param = lst_sku.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/searchAmountList',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'SearchWithdrawAmountList': function( promoter_id, page_index, page_size){
		// 申请提现
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' + promoter_id);
		lst_sku.push('page_index=' 	+ page_index);
		lst_sku.push('page_size=' 	+ page_size);
		var str_param = lst_sku.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/searchWithdrawAmountList',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'SearchWithdrawList': function(promoter_id, promoter_name, page_index, page_size){
		// 申请提现
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' + promoter_id);
		lst_sku.push('promoter_name=' + promoter_name);
		lst_sku.push('page_index=' 	+ page_index);
		lst_sku.push('page_size=' 	+ page_size);
		var str_param = lst_sku.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/searchWithdrawList',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'UpdateAmount': function(promoter_id, amount, amount_type, remark){
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' 	+ promoter_id);
		lst_sku.push('amount=' 		+ amount);
		lst_sku.push('amount_type=' 	+ amount_type);
		lst_sku.push('remark=' 	+ remark);
		var str_param = lst_sku.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/updateAmount',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'UpdatePromoterStatus': function(promoter_id,status,reject_reason){
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' 	+ promoter_id);
		lst_sku.push('reject_reason=' 	+ reject_reason);
		lst_sku.push('status=' 		+ status);
		var str_param = lst_sku.join('&');
		var result = null;
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/updatePromoterStatus',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'ResetPwd': function(promoter_id){
		// 申请提现
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' 	+ promoter_id);
		var str_param = lst_sku.join('&');

		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/resetPwd',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
};


OrderService = {
		'SearchOrderList': function(promoter_id, promoter_name, order_id, order_status, payment_status, begin_order_date, end_order_date, page_index, page_size){
			var lst_sku = new Array();
			lst_sku.push('promoter_id=' 		+ promoter_id);
			lst_sku.push('promoter_name='		+ promoter_name);
			lst_sku.push('order_id=' 			+ order_id);
			lst_sku.push('order_status=' 		+ order_status);
			lst_sku.push('payment_status=' 	+ payment_status);
			lst_sku.push('begin_order_date='	+ begin_order_date);
			lst_sku.push('end_order_date=' 	+ end_order_date);
			lst_sku.push('page_index=' 		+ page_index);
			lst_sku.push('page_size=' 		+ page_size);
			var str_param = lst_sku.join('&');

			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/searchOrderList',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'UpdateOrderStatus': function(order_id) {
			var lst_param = new Array();
			lst_param.push('order_id=' + order_id);
			var str_param = lst_param.join('&');
			var result = null;
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/updateorderstatus',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		
		'CancelOrder': function(order_id){
			var lst_sku = new Array();
			lst_sku.push('order_id='+ order_id);
			var str_param = lst_sku.join('&');

			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/cancelOrder',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
};


DealerService = {
		'UpdateDealer': function(dealer_id,dealer_name,  dealer_type, user_id ,
				discount_rate, business_leader, business_leader_cellphone, area_name , province_id,
				province_name ,city_id,city_name, operation_pattern , registered_capital , leal_person ,bank_name,bank_no,
				tax_no,finance_leader,finance_leader_cellphone,invoice_address,buy_count,first_buy_date,
				last_buy_date,remark,amount,points,sign_status,sign_date,contract_start_date,contract_end_date,
				register_date,register_ip,last_login_date,last_login_ip,status){
			var lst_dealer = new Array();
			lst_dealer.push('dealer_id=' 	+ dealer_id);
			lst_dealer.push('dealer_name=' 	+ dealer_name);
			lst_dealer.push('dealer_type=' 	+ dealer_type);
			lst_dealer.push('user_id=' 	+ user_id);
			lst_dealer.push('discount_rate=' 	+ discount_rate);
			lst_dealer.push('business_leader=' 	+ business_leader);
			lst_dealer.push('business_leader_cellphone=' 	+ business_leader_cellphone);
			lst_dealer.push('area_name=' 	+ area_name);
			lst_dealer.push('province_id=' 	+ province_id);
			lst_dealer.push('province_name=' 	+ province_name);
			lst_dealer.push('city_id=' 	+ city_id);
			lst_dealer.push('city_name=' 	+ city_name);
			lst_dealer.push('operation_pattern=' 	+ operation_pattern);
			lst_dealer.push('registered_capital=' 	+ registered_capital);
			lst_dealer.push('leal_person=' 	+ leal_person);
			lst_dealer.push('bank_name=' 	+ bank_name);
			lst_dealer.push('bank_no=' 	+ bank_no);
			lst_dealer.push('tax_no=' 	+ tax_no);
			lst_dealer.push('finance_leader=' 	+ finance_leader);
			lst_dealer.push('finance_leader_cellphone=' 	+ finance_leader_cellphone);
			lst_dealer.push('invoice_address=' 	+ invoice_address);
			lst_dealer.push('buy_count=' 	+ buy_count);
			lst_dealer.push('first_buy_date=' 	+ first_buy_date);
			lst_dealer.push('last_buy_date=' 	+ last_buy_date);
			lst_dealer.push('remark=' 	+ remark);
			lst_dealer.push('amount=' 	+ amount);
			lst_dealer.push('points=' 	+ points);
			lst_dealer.push('sign_status=' 	+ sign_status);
			lst_dealer.push('invoice_address=' 	+ invoice_address);
			lst_dealer.push('sign_date=' 	+ sign_date);
			lst_dealer.push('contract_start_date=' 	+ contract_start_date);
			lst_dealer.push('contract_end_date=' 	+ contract_end_date);
			lst_dealer.push('register_date=' 	+ register_date);
			lst_dealer.push('register_ip=' 	+ register_ip);
			lst_dealer.push('last_login_date=' 	+ last_login_date);
			lst_dealer.push('last_login_ip=' 	+ last_login_ip);
			lst_dealer.push('status=' 	+ status);
			var str_sku = lst_dealer.join('&');
			var result = null;
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/dealer/updateDealer',
				data : str_sku,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'AddDealer': function(dealer_name,  dealer_type, user_id ,
				discount_rate, business_leader, business_leader_cellphone, area_name , province_id,
				province_name ,city_id,city_name, operation_pattern , registered_capital , leal_person ,bank_name,bank_no,
				tax_no,finance_leader,finance_leader_cellphone,invoice_address,buy_count,first_buy_date,
				last_buy_date,remark,amount,points,sign_status,sign_date,contract_start_date,contract_end_date,
				register_date,register_ip,last_login_date,last_login_ip,status ){
			var lst_dealer = new Array();
			lst_dealer.push('dealer_name=' 	+ dealer_name);
			lst_dealer.push('dealer_type=' 	+ dealer_type);
			lst_dealer.push('user_id=' 	+ user_id);
			lst_dealer.push('discount_rate=' 	+ discount_rate);
			lst_dealer.push('business_leader=' 	+ business_leader);
			lst_dealer.push('business_leader_cellphone=' 	+ business_leader_cellphone);
			lst_dealer.push('area_name=' 	+ area_name);
			lst_dealer.push('province_id=' 	+ province_id);
			lst_dealer.push('province_name=' 	+ province_name);
			lst_dealer.push('city_id=' 	+ city_id);
			lst_dealer.push('city_name=' 	+ city_name);
			lst_dealer.push('operation_pattern=' 	+ operation_pattern);
			lst_dealer.push('registered_capital=' 	+ registered_capital);
			lst_dealer.push('leal_person=' 	+ leal_person);
			lst_dealer.push('bank_name=' 	+ bank_name);
			lst_dealer.push('bank_no=' 	+ bank_no);
			lst_dealer.push('tax_no=' 	+ tax_no);
			lst_dealer.push('finance_leader=' 	+ finance_leader);
			lst_dealer.push('finance_leader_cellphone=' 	+ finance_leader_cellphone);
			lst_dealer.push('invoice_address=' 	+ invoice_address);
			lst_dealer.push('buy_count=' 	+ buy_count);
			lst_dealer.push('first_buy_date=' 	+ first_buy_date);
			lst_dealer.push('last_buy_date=' 	+ last_buy_date);
			lst_dealer.push('remark=' 	+ remark);
			lst_dealer.push('amount=' 	+ amount);
			lst_dealer.push('points=' 	+ points);
			lst_dealer.push('sign_status=' 	+ sign_status);
			lst_dealer.push('invoice_address=' 	+ invoice_address);
			lst_dealer.push('sign_date=' 	+ sign_date);
			lst_dealer.push('contract_start_date=' 	+ contract_start_date);
			lst_dealer.push('contract_end_date=' 	+ contract_end_date);
			lst_dealer.push('register_date=' 	+ register_date);
			lst_dealer.push('register_ip=' 	+ register_ip);
			lst_dealer.push('last_login_date=' 	+ last_login_date);
			lst_dealer.push('last_login_ip=' 	+ last_login_ip);
			lst_dealer.push('status=' 	+ status);
			var str_sku = lst_dealer.join('&');
			var str_sku = lst_dealer.join('&');
			var result = null;
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/dealer/addDealer',
				data : str_sku,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	     	  error : function(e, err_name, err_text) {
	   		  result = {};
	   		  result.IsSuccess = 0;
	   		  result.ErrorMsg = err_text;
	   		  result.ErrorCode = 4;
	   	  }
			});
			return result;
		},
		
		
		 'GetUserID':function(){
		    	var result = null;
				$.ajax({
					type : 'post',
					url : '/AjaxService/center/dealer/getUserID',
					data : null,
					dataType : 'json',
					async : false,
					success : function(data) {
						result = data;
					},
		     	  error : function(e, err_name, err_text) {
		   		  result = {};
		   		  result.IsSuccess = 0;
		   		  result.ErrorMsg = err_text;
		   		  result.ErrorCode = 4;
		   	  }
				});
				return result;
			},
			 'AddDealerOrder':function(dealer_id){
				 
					var lst_dealer_data = new Array();
					lst_dealer_data.push('dealer_id=' 	+ dealer_id);
					var str_dealer_para = lst_dealer_data.join('&');
			    	var result = null;
					$.ajax({
						type : 'post',
						url : '/AjaxService/center/dealer/addDealerOrder',
						data : str_dealer_para,
						dataType : 'json',
						async : false,
						success : function(data) {
							result = data;
						},
			     	  error : function(e, err_name, err_text) {
			   		  result = {};
			   		  result.IsSuccess = 0;
			   		  result.ErrorMsg = err_text;
			   		  result.ErrorCode = 4;
			   	  }
					});
					return result;
				},'SubmitDealerOrder':function(dealer_id,select_address_id,sku_list_str,remark,payment_type,addDiscountAmount,subDiscountAmount,dealer_channel, dealer_cashback_amount){
					
					var lst_dealer_data = new Array();
					lst_dealer_data.push('dealer_id=' 	+ dealer_id);
					lst_dealer_data.push('select_address_id=' 	+ select_address_id);
					lst_dealer_data.push('sku_list_str=' 	+ sku_list_str);
					lst_dealer_data.push('remark=' 	+ remark);
					lst_dealer_data.push('payment_type=' +payment_type);
					lst_dealer_data.push('addDiscountAmount=' 	+ addDiscountAmount);
					lst_dealer_data.push('subDiscountAmount=' +subDiscountAmount);
					lst_dealer_data.push('dealer_channel='+dealer_channel);
					lst_dealer_data.push('dealer_cashback_amount='+dealer_cashback_amount);

					var str_dealer_para = lst_dealer_data.join('&');
			    	var result = null;
					$.ajax({
						type : 'post',
						url : '/AjaxService/center/dealer/submitDealerOrder',
						data : str_dealer_para,
						dataType : 'json',
						async : false,
						success : function(data) {
							result = data;
						},
			     	  error : function(e, err_name, err_text) {
			   		  result = {};
			   		  result.IsSuccess = 0;
			   		  result.ErrorMsg = err_text;
			   		  result.ErrorCode = 4;
			   	  }
					});
					return result;
				},'CheckDealerMinSalePrice':function(dealer_id,sku_list_str){
					
					var lst_dealer_data = new Array();
					lst_dealer_data.push('dealer_id=' 	+ dealer_id);
					lst_dealer_data.push('sku_list_str=' 	+ sku_list_str);

					var str_dealer_para = lst_dealer_data.join('&');
			    	var result = null;
					$.ajax({
						type : 'post',
						url : '/AjaxService/center/dealer/CheckDealerMinSalePrice',
						data : str_dealer_para,
						dataType : 'json',
						async : false,
						success : function(data) {
							result = data;
						},
			     	  error : function(e, err_name, err_text) {
			   		  result = {};
			   		  result.IsSuccess = 0;
			   		  result.ErrorMsg = err_text;
			   		  result.ErrorCode = 4;
			   	  }
					});
					return result;
				},'SearchDearlerForOrder':function(dealer_id,dealer_name,dealer_channel){
					
					
					var lst_dealer_data = new Array();
					lst_dealer_data.push('dealer_id=' 	+ dealer_id);
					lst_dealer_data.push('dealer_name=' 	+ dealer_name);
					lst_dealer_data.push('dealer_channel=' 	+ dealer_channel);
					var str_dealer_para = lst_dealer_data.join('&');
			    	var result = null;
					$.ajax({
						type : 'post',
						url : '/AjaxService/center/dealer/SearchDearlerForOrder',
						data : str_dealer_para,
						dataType : 'json',
						async : false,
						success : function(data) {
							result = data;
						},
			     	  error : function(e, err_name, err_text) {
			   		  result = {};
			   		  result.IsSuccess = 0;
			   		  result.ErrorMsg = err_text;
			   		  result.ErrorCode = 4;
			   	  }
					});
					return result;
				}
				
	};


OrderInfoListService = {
	'SearchOrderInfoList': function(order_id,dealer_id,dealer_name,order_status,payment_status,dealer_type,start_date,end_date,dealer_channel,page_index, page_size){
		var lst_order_detail = new Array();
		lst_order_detail.push('order_id=' 	+ order_id);
		lst_order_detail.push('dealer_id=' 	+ dealer_id);
		lst_order_detail.push('dealer_name=' 	+ dealer_name);
		lst_order_detail.push('order_status=' 	+ order_status);
		lst_order_detail.push('payment_status=' 	+ payment_status);
		lst_order_detail.push('dealer_type=' 	+ dealer_type);
		lst_order_detail.push('start_date=' 	+ start_date);
		lst_order_detail.push('end_date=' 	+ end_date);
		lst_order_detail.push('dealer_channel=' 	+ dealer_channel);
		lst_order_detail.push('page_index=' 	+ page_index);
		lst_order_detail.push('page_size=' 	+ page_size);
		var str_param = lst_order_detail.join('&');
		
		var result = null;
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/order/searchorderinfolist',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
};
	
